package net.optix.ip.commands
{
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import net.optix.ip.business.*;
	import net.optix.ip.events.PractitionerRegisterEvent;
	import net.optix.ip.model.ModelLocator;

	public class PractitionerRegisterCommand implements Command, Responder
	{
		// attributes ============================
		private var model : ModelLocator = ModelLocator.getInstance();

		public function PractitionerRegisterCommand():void
		{
			
		}
		// functions ============================
		public function execute( event:CairngormEvent ) : void
		{
			var myEvent:PractitionerRegisterEvent = PractitionerRegisterEvent( event );
			
			var delegate:UserDelegate = new UserDelegate();     
			delegate.practitionerRegister(this,myEvent.vo);	
			model.result	=	"Registering Firm ...";
		}
		
		//----------------------------------------------------------------------------
		public function onResult( event : * = null ) : void
		{
			model.result	=	event.result;
			if(model.result == "Successfully register practitioner")
			{
				model.close		=	"no";
				model.close		=	"yes";
			}
			model.bSubmit	=	true;
		}
		
		//----------------------------------------------------------------------------
		public function onFault( event : * = null ) : void
		{
			model.result	=	"Program error";	
			model.bSubmit	=	true;
		}

	}
}